<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><!DOCTYPE HTML>
<%-- <%@include file="edit.jsp"%> --%>
<html>
<head>
<script type="text/javascript">
	var groupId='${groupId}';
	$(function() {
		
		$('#toolbar').toolbar({buttons:[
			{name:'save',iconCls:'icon-save',text:'保存'}
	  	],handler:handler});
		//加载非圈子成员信息
		function loadNoMember(groupId){
			var param = {};
	    	param.groupId = groupId;
	    	$('#user_grid').datagrid({ 
	    		queryParams: param,
	    		url:"notInGroup"
	    	}); 
		}
		//成员信息
		$('#user_grid').datagrid({
		    pagination:true,singleSelect:true,rownumbers:true,striped:true,fitColumns:true,fit:true,
		    columns:[[
		    	{field:'ck',checkbox:true},
		    	{field:'nickname',title:'姓名'},
				{field:'username',title:'用户名'},
				{field:'type',title:'用户类型',formatter:function(v,r,i){
					return $codetext('userType',v)
				}},
				{field:'createdDt',title:'创建时间'},
				{field:'createdBy',title:'创建人'},
				{field:'updatedDt',title:'更改时间'},
				{field:'updatedBy',title:'更改人'},
				{field:'enabled',title:'启用标记',formatter:$g.bv}
		    ]]
		});
		
		loadNoMember(groupId);
		
	});
	function handler() {
		switch(this.name) {
			case 'save': toSave();break;
		}
	}
	function toSave(){
		$.messager.progress({title:'系统提示',text:'数据处理中，请耐心等待...'});
		var item = $('#user_grid').datagrid('getSelected');
		var params = [];
    	params[0]={name:"entity.userId",value:item.id};
    	params[1]={name:"entity.groupId",value:groupId};
		$.post('add',params,function(r) {
			$.messager.progress('close');
			if(r.code<0) return $alert(r.msg);
			top.$prompt('保存成功');
			top.$window.close(window,1,null);
		},'json');
	}
</script>
</head>
<body>
	<div id="toolbar" class="toolbar" ></div>
	<div class="easyui-layout" data-options="fit:true">
		<div data-options="region:'center',border:false" style="padding-bottom: 33px">
			<table id="user_grid"></table>
		</div>
	</div>
</body>
</html>